#include<stdio.h> struct worker { char name[20]; int wages; int wdays; }; main() { struct worker a[5]; int i,p,t=0; for(i=0;i<=4;i++) { printf("Enter Name wages and wdays "); scanf("%s %d %d",a[i].name,&a[i].wages,&a[i].wdays); } for(i=0;i<=4;i++) { p=a[i].wages*a[i].wdays; printf("\nPayment of %s is %d",a[i].name,p); t=t+p; } printf("\nTotal Payment is %d",t); }
Enter Name wages and wdays Amit 500 4 Enter Name wages and wdays Ram 400 2 Enter Name wages and wdays Gopal 200 6 Enter Name wages and wdays Rahul 300 4 Enter Name wages and wdays Deepak 450 5 Payment of Amit is 2000 Payment of Ram is 800 Payment of Gopal is 1200 Payment of Rahul is 1200 Payment of Deepak is 2250 Total Payment is 7450
#include<stdio.h> struct player { char name[20]; int runs; }; main() { struct player a[11]; int i,t=0; for(i=0;i<=10;i++) { printf("Enter Name and Runs "); scanf("%s %d",a[i].name,&a[i].runs); } for(i=0;i<=10;i++) { printf("\n%s %d",a[i].name,a[i].runs); t=t+a[i].runs; } printf("\nTotal Score is %d",t); }
Enter Name and Runs Amit 4 Enter Name and Runs Ram 5 Enter Name and Runs Rahul 2 Enter Name and Runs Gopal 6 Enter Name and Runs Raj 4 Enter Name and Runs Mona 3 Enter Name and Runs Sita 4 Enter Name and Runs Rohan 2 Enter Name and Runs Varun 5 Enter Name and Runs vijay 4 Enter Name and Runs Ajay 3 Amit 4 Ram 5 Rahul 2 Gopal 6 Raj 4 Mona 3 Sita 4 Rohan 2 Varun 5 vijay 4 Ajay 3 Total Score is 42